/*
 * Created by 岱青海蓝信息系统(北京)有限公司 on 17-2-17 下午4:06
 * Copyright (c) 2017. All rights reserved.
 */

package com.example.dqhl.recycleviewdemo.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.dqhl.recycleviewdemo.R;
import com.example.dqhl.recycleviewdemo.adapter.CoordinatorAdapter;

import java.util.ArrayList;
import java.util.List;

public class CoordinatorTabLayoutFragment extends Fragment {

    private RecyclerView recyclerview;
    private CoordinatorAdapter coordinatorAdapter;

    private List<String> stringList;
    private static final String ARG_TITLE = "title";
    private String mTitle;


    public static CoordinatorTabLayoutFragment getIntence(String title){
        CoordinatorTabLayoutFragment fra = new CoordinatorTabLayoutFragment();
        Bundle bundle = new Bundle();
        bundle.putString(ARG_TITLE, title);
        fra.setArguments(bundle);
        return fra;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        mTitle = bundle.getString(ARG_TITLE);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_coordinator_tab_layout, container, false);
        initView(view);
        return  view;
    }

    private void initView(View view) {
        (recyclerview) = (RecyclerView) view.findViewById(R.id.recyclerview);
        recyclerview.setLayoutManager(new LinearLayoutManager(recyclerview.getContext()));
        stringList = new ArrayList<>();
        for(int i = 0;i<20;i++){
            stringList.add(mTitle +i);
        }
        recyclerview.setAdapter(coordinatorAdapter = new CoordinatorAdapter(recyclerview.getContext(),stringList));

    }
}
